

import { LuaFactory } from 'wasmoon'

async function dolua() {
    const factory = new LuaFactory()
    const lua = await factory.createEngine()
    
    try {
        lua.global.set('sleep', (length: number | undefined) => new Promise((resolve) => setTimeout(resolve, length)))
        await lua.doString(`
            sleep(1000):await()
            print("lua in vm...")
        `)
    } finally {
        lua.global.close()
    }
}


export function test_wasmoon() {
    console.log("===>Test: test_wasmoon()");
    dolua()
}